package top.fzqblog.firstapp;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import butterknife.BindView;
import butterknife.ButterKnife;
import rx.Subscriber;
import top.fzqblog.adapter.GlideAdapter;
import top.fzqblog.model.Meizi;
import top.fzqblog.service.RequestService;
/**
 * Created by 抽离 on 2017/9/26 0026.
 */

public class RxjavaRetrofitGlide extends AppCompatActivity{

    @BindView(R.id.recycleviewlayout)
    public RecyclerView recyclerView;

    private GlideAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycleviewtest);
        ButterKnife.bind(this);
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        RequestService requestService = new RequestService();
        requestService.getMeizi(new Subscriber<Meizi>() {
            @Override
            public void onCompleted() {
                Log.i("tag", "onCompleted");
            }

            @Override
            public void onError(Throwable throwable) {
                Log.i("tag", throwable.toString());
            }

            @Override
            public void onNext(Meizi meizi) {
                adapter = new GlideAdapter(RxjavaRetrofitGlide.this, meizi);
                recyclerView.setAdapter(adapter);
            }
        }, "福利", 20, 1);
    }
}
